package com.newbingo.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import com.newbingo.dao.imple.IBettingCellDao;
import com.newbingo.dao.imple.IGamePlayDao;
import com.newbingo.entity.BettingCell;
import com.newbingo.entity.GamePlay;
import com.newbingo.service.imple.IBettingCellService;
import com.newbingo.util.Pager;

public class BettingCellService implements IBettingCellService {
	private IBettingCellDao bettingCellDao;
	private IGamePlayDao gamePlayDao;


	/**
	 * 添加投注格，先根据bettingCell查询出的游戏玩法，并保存到bettingcell中，进行保存
	 */
	public void createCell(BettingCell bettingCell){
		bettingCell.setGamePlay(gamePlayDao.findById(bettingCell.getGamePlay().getId()));
		bettingCellDao.save(bettingCell);
	}
	
	/**
	 * 删除投注格
	 */
	public void deleteCell(BettingCell bettingCell){
		bettingCellDao.delete(bettingCell);
	}
	
	/**
	 * 更新投注格信息，先根据bettingCell查询出的游戏玩法，并保存到bettingcell中，进行级联更新
	 */
	public void updateCell(BettingCell bettingCell){
		bettingCell.setGamePlay(gamePlayDao.findById(bettingCell.getGamePlay().getId()));
		bettingCellDao.merge(bettingCell);
	}
	
	public Pager findCellByPage(int start,int limit,Object name){
		return bettingCellDao.findByPage(start, limit, name);
	}

	public IBettingCellDao getBettingCellDao() {
		return bettingCellDao;
	}

	public void setBettingCellDao(IBettingCellDao bettingCellDao) {
		this.bettingCellDao = bettingCellDao;
	}
	
	public IGamePlayDao getGamePlayDao() {
		return gamePlayDao;
	}

	public void setGamePlayDao(IGamePlayDao gamePlayDao) {
		this.gamePlayDao = gamePlayDao;
	}

	public BettingCell findById(Integer id) {
		return bettingCellDao.findById(id);
	}


}
